/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/

#ifndef _IMU_FILE_READER_HPP
#define _IMU_FILE_READER_HPP

#include "owndebug.h"
#include <string>
#include "IMUData.hpp"
#include "gimutils.h"
#include "ownutils.h"
#include <map>
#include <list>
#include <string>
#include <stdio.h>
typedef std::map<gim::time,MaCI::IMU::CIMUData *> TIMUDataMap;

class CIMUFileReader{
public:
  /**
   * Constructor
   */
  CIMUFileReader();

  /**
   * Destructor
   */
  ~CIMUFileReader();

  /**
   * Opens file with wanted filename
   */
  bool ReadFile(std::string aFileName);

  
  bool GetServiceInformation(std::string &aMaCIGroup,
                             std::string &aInstanceName);

  bool GetTimes(std::list<gim::time> &aTimes);
  bool GetTimeLimits(gim::time &aBegin,gim::time &aEnd);

  bool GetAllData(TIMUDataMap &aData);
  

  bool GetIMUData(MaCI::IMU::CIMUData &aData,
                  gim::time aTime);
                                    
  bool GetAcceleration3d( MaCI::IMU::TAcceleration3d &aAcceleration,
                         gim::time aTime);

  bool GetAngularVelocity3d(MaCI::IMU::TAngularVelocity3d &aAngularVelocity,
                            gim::time aTime);

  bool GetAngle3d(MaCI::IMU::TAngle3d &aAngle,
                  gim::time aTime);

  bool GetQuaternion(MaCI::IMU::TQuaternion &aQuaternion,
                     gim::time aTime);

  bool GetOrientationMatrix(MaCI::IMU::TOrientationMatrix &aOrientationMatrix,
                            gim::time aTime);
  
private:
  bool iFileReaded;  
  TIMUDataMap iData;
  std::list<gim::time> iTimes;
  gim::time iBegin;
  gim::time iEnd;
  std::string iMaCIGroup;
  std::string iInstanceName;
 


  bool ReadData(FILE *iFile);
  
  CIMUFileReader(const CIMUFileReader&)
    :iFileReaded(false),
     iData(),
     iTimes(),
     iBegin(),
     iEnd(),
     iMaCIGroup(""),
     iInstanceName("")
  {}

  CIMUFileReader &operator=(const  CIMUFileReader&){return *this;}

};
#endif ///< _IMU_FILE_READER_HPP
